import requests

# corpid = 'ww32f5df9a2517b554'
# corpsecret = 'nuNw29ZfaeuyYVhV1qrckKSn12Z7Lmntp3whCMbJF1w'
# url = f'https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={corpid}&corpsecret={corpsecret}'
# # print(url)
# rep = requests.get(url=url)
# print(rep)
# print(rep.text)

token = "XJ5SGjaZd2_fVvVq3vsNw_M5nlAYi7zELxh7kPomYJGR843OAQFPqgLpfHW6AW5scB2nbxRqGA853M818cF1OrQ6ZPW_EShXinafNZkgQTGkrTQo0-oVxNW83zlq1p3-T51-3foE69i9Un9RhYtNFjeQL9wWZ7BkMZfUfDzDfCUMMzhvdS4duWtNqQonFUISh3qbD9_YWCg2PmXiN3qEig"
# url = "https://qyapi.weixin.qq.com/cgi-bin/department/list"
# params = {
#     "access_token": token
# }
# rep = requests.get(url=url, params=params)
# print(rep.text)

# import random
# import json
# # url = f'https://qyapi.weixin.qq.com/cgi-bin/department/create?access_token={token}'
# url = f'https://qyapi.weixin.qq.com/cgi-bin/department/create'
#
# params = {
#     "access_token": token
# }
#
# json_data = {
#     "name": "我的测试部门"+str(random.randint(10, 99)),
#     "parentid": 1
# }
#
# str_data = json.dumps(json_data)
# # print(type(json_data))
# # print(type(str_data))
# # print(str_data)
# rep = requests.post(url=url, params=params, data=str_data)
# rep = requests.post(url=url, params=params, json=json_data)
#
# print(rep.text)

# url = "https://nmtp.youdao.com/api/organize/1514708/image/upload"
#
# header = {
#     "Cookie": "_ga=GA1.2.1193743571.1646906746; OUTFOX_SEARCH_USER_ID_NCOO=37296470.23531183; OUTFOX_SEARCH_USER_ID=\"1446041502@10.110.96.154\"; _gid=GA1.2.337720219.1654693575; SESSION=2d65c0af-dcb4-48d7-b798-218d565226a3; NTES_SESS=v6JgwWAvoFT3Ayu7aKwz8bPb3FBm7B1Wy7bsHOZBHo1SqC5iqgFBt6d4oYJL3Hnx0A9ok720dHugra8J2rt4KWahG0j3gOK1at3DEXKHW8Nc88J1yjNlX8HRXKZmV6uDKn1oKHOU_75atUQShyTe6pji55G2DLBj832HPjmRh3o0PidB.LLc0TI_D1qoMjzu722FdOv0BqVAkRZw.F7r3bNrU; S_INFO=1654693616|0|##|974381044@qq.com; P_INFO=974381044@qq.com|1654693616|0|youdao_jianwai|00&99|CN&1652703000&youdao_jianwai#CN&null#10#0#0|&0||974381044@qq.com"
# }
# p_data = open(r"C:\TT\习知\课件\我的课件\1624958787.png", "rb")
# files = {'file': p_data}
# rep = requests.post(url=url, headers=header, files=files)
# print(rep.text)

url = 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic2.zhimg.com%2Fv2-4a853117f103cd2ae0adc8b4bf13b15d_1440w.jpg%3Fsource%3D172ae18b&refer=http%3A%2F%2Fpic2.zhimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1657286206&t=72a7f90279340d38a4eb3b93de34f1b5'
# rep = requests.get(url=url)
# print(rep.content)
rep = requests.request("get", url=url)
with open(r'.\002.jpg', 'wb') as f:
    f.write(rep.content)

# requests.get()
# requests.request("get")
# requests.post()
# requests.put()